home *** CD-ROM | disk | FTP | other *** search
/ Aminet 22 / Aminet 22 (1997)(GTI - Schatztruhe)[!][Dec 1997].iso / Aminet / dev / misc / WHDLoaddev.lha / WHDLoad / Src / slave-examples / oscar.asm < prev    next >
Assembly Source File  |  1997-08-31  |  3KB  |  159 lines

  1. ;*---------------------------------------------------------------------------
  2. ;  :Program.    oscar.asm
  3. ;  :Contents.    Slave for "Oscar"
  4. ;  :Author.    BJ
  5. ;  :History.    20.05.96
  6. ;        16.06.97 updated for slave version 2
  7. ;        15.08.97 update for key managment
  8. ;  :Requires.    -
  9. ;  :Copyright.    Public Domain
  10. ;  :Language.    68000 Assembler
  11. ;  :Translator.    Barfly V1.131
  12. ;  :To Do.
  13. ;---------------------------------------------------------------------------*
  14.  
  15.     INCDIR    Includes:
  16.     INCLUDE    whdload.i
  17.  
  18.     OUTPUT    wart:oscar/oscar.slave
  19.     BOPT    O+ OG+            ;enable optimizing
  20.     BOPT    w4-            ;disable 64k warnings
  21.  
  22. ;======================================================================
  23.  
  24. _base        SLAVE_HEADER        ;ws_Security + ws_ID
  25.         dc.w    4        ;ws_Version
  26.         dc.w    WHDLF_NoError    ;ws_flags
  27. _upchip        dc.l    $177000        ;ws_BaseMemSize
  28.         dc.l    $300        ;ws_ExecInstall
  29.         dc.w    _Start-_base    ;ws_GameLoader
  30.         dc.w    _dir-_base    ;ws_CurrentDir
  31.         dc.w    0        ;ws_DontCache
  32. _keydebug    dc.b    $58        ;ws_keydebug = F9
  33. _keyexit    dc.b    $59        ;ws_keyexit = F10
  34.  
  35. _dir        dc.b    "data",0,0
  36.  
  37. ;======================================================================
  38.  
  39.     DOSCMD    "WDate >T:date"
  40.         dc.b    "$VER:"
  41.     INCBIN    "T:date"
  42.         dc.b    0
  43.  
  44. ;======================================================================
  45. _Start        ;    A0 = resident loader
  46. ;======================================================================
  47.  
  48.         lea    (_resload,pc),a1
  49.         move.l    a0,(a1)            ;save for later using
  50.  
  51.         move.l    #CACRF_EnableI,d0    ;enable instruction cache
  52.         move.l    d0,d1            ;mask
  53.         jsr    (resload_SetCACR,a0)
  54.  
  55.         lea    _10,a0
  56.         move.l    (.freemem),a1
  57.         move.l    (_resload),a2
  58.         jsr    (resload_LoadFileDecrunch,a2)
  59.         lea    .freemem,a0
  60.         add.l    d0,(a0)
  61.  
  62.         patch    $400+$8b4e,.allocmem    ;emulate this
  63.         nops    ($2a8-$276)/2,$400+$276    ;disable some os-stuff
  64.         patch    $400+$7b1a,_loader
  65.         add.l    #$99fc+$400-$9b64,$838+$400    ;copylock
  66.         jmp    $43e            ;start the dance
  67.  
  68. .allocmem    lea    .freemem,a0        ;this emulates "exec.AllocMem"
  69.         move.l    (a0),a1
  70.         add.l    d0,(a0)
  71.         move.l    (a0),d1
  72.         cmp.l    (_upchip),d1
  73.         blo    .1
  74.     illegal                    ;if basemem must increased
  75. .1        move.l    a1,a0
  76.         addq.l    #7,d0
  77.         lsr.l    #3,d0
  78. .clr        clr.l    (a0)+
  79.         clr.l    (a0)+
  80.         subq.l    #1,d0
  81.         bne    .clr
  82.         move.l    a1,d0
  83.         rts
  84.  
  85. .freemem    dc.l    $400            ;start point of free memory
  86.  
  87. _10        dc.b    "exe",0
  88.     EVEN
  89.  
  90. ;--------------------------------
  91.  
  92. _loader        addq.l    #4,a0            ;skip "df0:"
  93.         move.l    a2,-(a7)
  94.         move.l    (_resload),a2
  95.         jsr    (resload_LoadFileDecrunch,a2)
  96.         move.l    (a7)+,a2
  97.         bsr    _kinit
  98.         moveq    #0,d0            ;return code
  99.         rts
  100.  
  101. ;--------------------------------
  102.  
  103. _kinit        movem.l    a0-a1,-(a7)
  104.         lea    (_keyboard,pc),a1
  105.         cmp.l    $68,a1
  106.         beq    .q
  107.         lea    (_realint68,pc),a0
  108.         move.l    $68,(a0)
  109.         move.l    a1,$68
  110. .q        movem.l    (a7)+,a0-a1
  111.         rts
  112.  
  113. _realint68    dc.l    0
  114.  
  115. _keyboard    move.l    d0,-(a7)
  116.         move.b    $bfec01,d0
  117.         ror.b    #1,d0
  118.         not.b    d0
  119.  
  120. ; RAW-Key-Codes:
  121. ;    ESC    $45
  122. ;    DEL    $46
  123. ;    F1..F10    $50..$59
  124. ;    HELP    $5f
  125.  
  126.         cmp.b    (_keydebug),d0
  127.         bne    .1
  128.         move.l    (a7)+,d0
  129.         move.w    (a7),(6,a7)        ;sr
  130.         move.l    (2,a7),(a7)        ;pc
  131.         clr.w    (4,a7)            ;ext.l sr
  132.         bra    _debug            ;coredump & quit
  133. .1
  134.         cmp.b    (_keyexit),d0
  135.         beq    _exit            ;exit
  136.         cmp.b    #$45,d0
  137.         beq    _exit            ;exit
  138.  
  139.         move.l    (a7)+,d0
  140.         move.l    (_realint68),-(a7)    ;enter orginal rou.
  141.         rts
  142.  
  143. ;--------------------------------
  144.  
  145. _resload    dc.l    0            ;address of resident loader
  146.  
  147. ;--------------------------------
  148.  
  149. _exit        pea    TDREASON_OK.w
  150.         bra    _end
  151. _debug        pea    TDREASON_DEBUG.w
  152. _end        move.l    (_resload),-(a7)
  153.         add.l    #resload_Abort,(a7)
  154.         rts
  155.  
  156. ;======================================================================
  157.  
  158.     END
  159.